home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
TCL1
/
JOHNLOVE
/
C_SOURCE
/
HELP.C
< prev
next >
Wrap
Text File
|
1992-01-17
|
5KB
|
221 lines
/*********************************************************
"help.c"
by John A. Love, III [Washington Apple Pi Users' Group]
using Symantec's "THINK C", v 5.00
*********************************************************/
#include <GestaltEqu.h>
#include <OSChecks.h>
#include <Traps.h>
#include "CmyGlobals.h"
#include "help.h"
// Local prototype(s):
OSErr ShowMyNewBalloon (Rect *altRect,
Ptr tipProc,
short strID,
short strIndex,
short theProc,
short variant,
short method);
Point mouse;
short notMine = -1;
Boolean HelpManagerActive (void) {
/* Do we have a machine on which the Help Manager exists ??? */
short _Gestalt = 0xA1AD;
long myFeature;
Boolean result;
result = false;
;
if (TrapAvailable(_Gestalt)) {
if (Gestalt(gestaltHelpMgrAttr, &myFeature) == noErr) {
if (BitTst(&myFeature, 31 - gestaltHelpMgrPresent)) result = true;
}
}
return(result);
} /* HelpManagerActive */
Boolean BalloonsOn (void) {
/* Has the user selected "Show Balloons" ??? */
return(HelpManagerActive() && HMGetBalloons());
} /* BalloonsOn */
Boolean BalloonShowing (void) {
/* Is a Balloon currently showing ??? */
return(HelpManagerActive() && HMIsBalloon());
} /* BalloonShowing */
void HideBalloons (Boolean balloonsUp) {
OSErr soWhat;
if (balloonsUp) {
/* Get the daggum monster out of the way !! */
/* Used "hmSaveBitsNoWindow option" so bits */
/* are restored withOUT an update Event. */
if (BalloonShowing()) soWhat = HMRemoveBalloon();
/* Okay, I've restored the bits. However, now */
/* I've got to temporarily disable Balloon Help */
/* until I leave with a Mouse Up Event or finish */
/* with whatever: */
soWhat = HMSetBalloons(false);
;
gLastBalloon = -1;
} /* "Show Balloons" active */
} /* HideBalloons */
void ShowBalloons (Boolean balloonsUp) {
/* NOW !!! I can safely re-enable Balloon Help: */
OSErr soWhat;
if (balloonsUp) soWhat = HMSetBalloons(true);
} /* ShowBalloons */
void ResetBalloons (Boolean balloonsUp) {
if (balloonsUp) ShowBalloons(true);
else HideBalloons(HelpManagerActive());
} /* ResetBalloons */
OSErr ShowMyNewBalloon (Rect *altRect,
Ptr tipProc,
short strID,
short strIndex,
short theProc,
short variant,
short method) {
HMMessageRecord helpMsg;
Point tip;
Rect cyAltRect;
/* See comment besides "nil" passed to HMShowBalloon below:
// ... so we don't change the input Rect:
cyAltRect = *altRect;
LocalGlobal(&cyAltRect);
// If we centered the tip and the window is partially
// hidden by, say, a Floating Window, the tip may end
// up pointing to the Floating Window:
/*
// Center the tip:
SetPt(&tip,
(cyAltRect.right + cyAltRect.left)/2,
(cyAltRect.bottom + cyAltRect.top )/2);
*/
GetMouse(&tip);
LocalToGlobal(&tip);
// Fill in HMMessageRecord:
helpMsg.hmmHelpType = khmmStringRes;
helpMsg.u.hmmStringRes.hmmResID = strID;
helpMsg.u.hmmStringRes.hmmIndex = strIndex;
;
return ( HMShowBalloon(&helpMsg, tip,
nil, /* If I pass &cyAltRect, the Help Manager
** will attempt to re-calculate the tip.
** This is exactly what I do NOT want
** because of the possibility that a
** Floating Window may be covering part
** of a DLOG item in which case the
** re-calculated tip may end up pointing
** to the Floating Window. */
tipProc, theProc, variant, method) );
} /* ShowMyNewBalloon */
void FindAndShowDynamicBalloons (Boolean balloonsUp) {
short stdWDEF = 0, defVar = 0;
short part, activeOtherWindow = -1000;
EventRecord macEvent;
GrafPtr savePort;
WindowPtr inWindow;
if ( !balloonsUp ||
EventAvail(updateMask, &macEvent) /* "Switch-A_Roo" problem */ ) {
gLastBalloon = notMine;
return;
}
GetMouse(&mouse);
LocalToGlobal(&mouse);
part = FindWindow(mouse, &inWindow);
if (part != inContent) return;
else { /* mouse is in a window somewhere */
GetPort(&savePort);
SetPort(inWindow);
GlobalToLocal(&mouse);
if ( inWindow == FrontWindow() ) {
/* mouse in front, or active window */
} /* Cursor in SOME active window */
else /* Cursor in an inactive window */ {
/* The 'hovr' resource handles this case. */
} /* Cursor in SOME inactive window */
SetPort(savePort);
} /* Mouse is somewhere in a window */
} /* FindAndShowDynamicBalloons */
/* { end file "help.c" } */